package utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.parts;

import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.XYLayout;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.LayoutEditPolicy;
import org.eclipse.gef.editpolicies.ResizableEditPolicy;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ListCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.CreationEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableCompartmentEditPolicy;
import org.eclipse.gmf.runtime.diagram.ui.figures.CanonicalShapeCompartmentLayout;
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.draw2d.ui.figures.ConstrainedToolbarLayout;
import org.eclipse.gmf.runtime.notation.View;

import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.policies.ControlFlowSegmentControlFlowSegmentCompartmentCanonicalEditPolicy;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.edit.policies.ControlFlowSegmentControlFlowSegmentCompartmentItemSemanticEditPolicy;
import utn.frsf.cidisi.upcolbpip.interactionprotocols.diagram.part.Messages;
import utn.frsf.cidisi.upcolbpip.util.layout.ExtendedResizableCompartmentFigure;

/**
 * @generated
 */
public class ControlFlowSegmentControlFlowSegmentCompartmentEditPart extends
		ListCompartmentEditPart {

	/**
	 * @generated
	 */
	public static final int VISUAL_ID = 7001;

	/**
	 * @generated
	 */
	public ControlFlowSegmentControlFlowSegmentCompartmentEditPart(View view) {
		super(view);
	}

	/**
	 * @generated
	 */
	protected boolean hasModelChildrenChanged(Notification evt) {
		return false;
	}

	/**
	 * @generated
	 */
	public String getCompartmentName() {
		return Messages.ControlFlowSegmentControlFlowSegmentCompartmentEditPart_title;
	}

	/**
	 * @generated NOT
	 */
	public IFigure createFigure() {
		//		ResizableCompartmentFigure result = (ResizableCompartmentFigure) super
		//				.createFigure();
		ExtendedResizableCompartmentFigure result = new ExtendedResizableCompartmentFigure(
				getCompartmentName(), getMapMode());

		ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout();
		layout.setVertical(true);
		layout.setStretchMajorAxis(true);
		layout.setStretchMinorAxis(true);
		layout.setMinorAlignment(ConstrainedToolbarLayout.ALIGN_CENTER);
		result.getContentPane().setLayoutManager(layout);

		//		CanonicalShapeCompartmentLayout layout = new CanonicalShapeCompartmentLayout();
		////		layout.

		result.setTitleVisibility(false);
		return result;
	}

	/**
	 * @generated
	 */
	protected void createDefaultEditPolicies() {
		super.createDefaultEditPolicies();
		installEditPolicy(
				EditPolicyRoles.SEMANTIC_ROLE,
				new ControlFlowSegmentControlFlowSegmentCompartmentItemSemanticEditPolicy());
		installEditPolicy(EditPolicyRoles.CREATION_ROLE,
				new CreationEditPolicy());
		installEditPolicy(EditPolicyRoles.DRAG_DROP_ROLE,
				new DragDropEditPolicy());
		installEditPolicy(
				EditPolicyRoles.CANONICAL_ROLE,
				new ControlFlowSegmentControlFlowSegmentCompartmentCanonicalEditPolicy());
	}

	/**
	 * @generated
	 */
	protected void setRatio(Double ratio) {
		if (getFigure().getParent().getLayoutManager() instanceof ConstrainedToolbarLayout) {
			super.setRatio(ratio);
		}
	}

}
